package com.gexin.controller.system.order;

import com.gexin.core.web.SystemBaseController;
import com.gexin.model.order.OrderItem;
import com.gexin.model.product.ProductSku;
import com.jfinal.ext.route.ControllerBind;

import java.util.List;

@ControllerBind(controllerKey = "/system/order/edit", viewPath = "WEB-INF/system/order")
public class OrderEditController extends SystemBaseController {

	public void  index(){
		
	}
	
	public void sku_list(){
		List<ProductSku>  sku_list = ProductSku.dao.getStockByProducts(getParaToInt());
		success(sku_list);
	}
	
	public void edit_sku(){
		OrderItem item =  OrderItem.dao.findById(getParaToInt("item_id"));
		if(item!=null){
			ProductSku sku =  ProductSku.dao.findById(getPara("sku_id"));
			if(sku.getStockCount()>0){
				item.setSkuCode(sku.getSkuCode());
				item.setSkuText(sku.getSkuText());
				item.setSkuId(sku.getSkuId());
				item.update();
				success(item.getSkuText());
			}else{
				fail("库存数量不足！");
			}
		}else{
			fail("参数错误！");
		}
	}
}


